home *** CD-ROM | disk | FTP | other *** search
- package asp.wizard;
-
- import asp.wizard.util.UiUtil;
- import com.sun.java.swing.CellEditor;
- import com.sun.java.swing.JComboBox;
- import com.sun.java.swing.JTable;
- import com.sun.java.swing.table.DefaultTableModel;
- import java.awt.Component;
- import java.util.Vector;
-
- public class WizardViewSubDbQueryWhere extends WizardViewAbstract {
- private static WizardViewAbstract _instance = null;
- private WVPanelDbQueryWhere _mainPanel;
-
- protected void addRow() {
- this.cancelTableCellEditing();
- Vector tableRow = new Vector();
- tableRow.setSize(5);
- this._mainPanel._tbmCriteria.addRow(tableRow);
- }
-
- protected void deleteRow() {
- this.cancelTableCellEditing();
- DefaultTableModel tableModel = this._mainPanel._tbmCriteria;
- JTable table = this._mainPanel._tblCriteria;
- int[] selRows = table.getSelectedRows();
- int delRowCount = selRows.length;
- boolean delAll = delRowCount == table.getRowCount();
-
- for(int i = 0; i < delRowCount; ++i) {
- if (i == delRowCount - 1 && delAll) {
- for(int j = 0; j < tableModel.getColumnCount(); ++j) {
- tableModel.setValueAt((Object)null, selRows[i] - i, j);
- }
- } else {
- tableModel.removeRow(selRows[i] - i);
- }
- }
-
- if (delRowCount > 0) {
- ((Component)table).repaint();
- table.setRowSelectionInterval(selRows[0] - 1, selRows[0] - 1);
- }
-
- }
-
- public DefaultTableModel getWhereData() {
- return this._mainPanel._tbmCriteria;
- }
-
- public static WizardViewAbstract getInstance() {
- if (_instance == null) {
- _instance = new WizardViewSubDbQueryWhere();
- }
-
- return _instance;
- }
-
- private void cancelTableCellEditing() {
- CellEditor cellEditor = this._mainPanel._tblCriteria.getCellEditor();
- if (cellEditor != null) {
- cellEditor.cancelCellEditing();
- }
-
- }
-
- protected void createMainPanel() {
- this._mainPanel = new WVPanelDbQueryWhere();
- this._mainPanel._btnAdd.addActionListener(new 1(this));
- this._mainPanel._btnDelete.addActionListener(new 2(this));
- }
-
- public WVPanelBase getMainPanel() {
- return this._mainPanel;
- }
-
- public void setSuffixes(Vector values) {
- UiUtil.populateCombo(this._mainPanel._cboCritSuffix, values);
- }
-
- public void setOperators(Vector values) {
- UiUtil.populateCombo(this._mainPanel._cboOperator, values);
- }
-
- public void setPrefixes(Vector values) {
- UiUtil.populateCombo(this._mainPanel._cboCritPrefix, values);
- }
-
- public JComboBox getcboLhs() {
- return this._mainPanel._cboLhs;
- }
-
- public JComboBox getcboRhs() {
- return this._mainPanel._cboRhs;
- }
-
- public void commit() {
- CellEditor cellEditor = this._mainPanel._tblCriteria.getCellEditor();
- if (cellEditor != null) {
- cellEditor.stopCellEditing();
- }
-
- }
- }
-